package org.ascollada.core
{
	import org.ascollada.ASCollada;
	import org.ascollada.core.log.DaeLogger;
	
	public class DaeInstanceNode extends DaeElement
	{
		/** */
		public var url		:String;
		
		/**
		 * 
		 */
		public function DaeInstanceNode(document:DaeDocument, node:XML=null)
		{
			super(document, node);
		}
		
		/**
		 * Reads the node.
		 * 
		 * @param	node
		 */ 
		public override function read( node:XML ):void
		{
			if ( !validateElement(node.name().localName) )
			{
				DaeLogger.error("Not a " + ASCollada.DAE_INSTANCE_NODE_ELEMENT + " element!");
				throw new Error("Not a " + ASCollada.DAE_INSTANCE_NODE_ELEMENT + " element!");
			}
			
			super.read( node );
			
			this.url = stripPound( node.@url.toString() );
		}
		
		/**
		 * Validate the element to be read.
		 * 
		 * @param	nodeName
		 * 
		 * @return
		 */ 
		public override function validateElement( nodeName:String ) : Boolean
		{
			return (nodeName == ASCollada.DAE_INSTANCE_NODE_ELEMENT);
		}	
	}
}